GBML manual / Maps

map_length

How many key/value pairs target currently holds - 0 for an empty map, up to target's own declared capacity once it is full.

Syntax

map_length(target) -> int

Arguments

NameType
targetmap

Returns

int

Description

How many key/value pairs target currently holds - 0 for an empty map, up to target's own declared capacity (/// @capacity, always a power of two - see map_set) once it is full.

Example

/// @type {map<string,int>}
var scores = {};
map_set(scores, "alice", 10);
map_set(scores, "bob", 20);
var count = map_length(scores); // 2
A real capture - an empty map, map_length reading 0A real capture - an empty map, map_length reading 0
A real capture - an empty map, map_length reading 0
The same map after two map_set calls - alice and bob both present, map_length now 2The same map after two map_set calls - alice and bob both present, map_length now 2
The same map after two mapset calls - alice and bob both present, maplength now 2

On the GBA

Just the hash map's size() - O(1).

See also: map_setmap_removemap_clearmap_hasData containers